// game level info,should resetting by user when choose game level
var g_gameLevel = 0;
var g_chooser = null;

JudgeGameState=function(){
    // emitter next group enemy
    if( EmptyEnemy() ){
        if( LevelFinish() ){
            cc.log("is play next level??");
            NextLevel();
        }else{
            cc.log("emitter next group");
            EmissionEnemy();
        }
    }
}
/////////////////  next level /////////////////
var NextLevel=function(){
    // update level
    if(++g_gameLevel>=MaxLevel()){
        cc.log("all level end,resetting level to 0");
        g_gameLevel = 0;
        g_mainScene.addChild( new EndLayer(),50 );
        RemoveMainLayer(true);
    }else{
        g_mainScene.addChild( new TransLayer(),50 );
    }
}

///////////////// tower process /////////////////
Register = function(x,y,registerobj){
    var jsonMap = GetJsonMap();
    if( jsonMap ){
        jsonMap.register(x,y,registerobj);
    }else{
        cc.log("json map is invalid");
    }
}
Register1 = function(point,registerobj){
    var jsonMap = GetJsonMap();
    if( jsonMap ){
        jsonMap.register1(point,registerobj);
    }else{
        cc.log("json map is invalid");
    }
}
Unregister = function(x,y){
    var jsonMap = GetJsonMap();
    if( jsonMap ){
        jsonMap.unregister(x,y);
    }else{
        cc.log("json map is invalid");
    }
}
Unregister1 = function(point){
    var jsonMap = GetJsonMap();
    if( jsonMap ){
        jsonMap.unregister1(point);
    }else{
        cc.log("json map is invalid");
    }
}
